<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _encode_personality(self, personality):
 """ Personality files must be base64-encoded before transmitting. """

        if personality is None:
            personality = []
        else:
            personality = utils.coerce_to_list(personality)
            for pfile in personality:
                if "contents" in pfile:
                    pfile["contents"] = base64.b64encode(pfile["contents"])
        return personality