<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def exportpub(self, format="PEM"):
 """ Returns public key as PEM or DER structure. """

        bio = Membio()
        if format == "PEM":
            retcode = libcrypto.PEM_write_bio_PUBKEY(bio.bio, self.key)
        else:
            retcode = libcrypto.i2d_PUBKEY_bio(bio.bio, self.key)
        if retcode == 0:
            raise PKeyError("error serializing public key")
        return str(bio)