<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pem(self):
 """ Serialize in PEM format """

        bio = Membio()
        if not libcrypto.PEM_write_bio_CMS(bio.bio, self.ptr):
            raise CMSError("writing CMS to PEM")
        return str(bio)