I just picked the encode method analagous to base64.decodestring, which I got from the email.utils._bdecode docstring:

_bdecode(s)
    Decodes a base64 string.
    
    This function is equivalent to base64.decodestring and it's retained only
    for backward compatibility. It used to remove the last \n of the decoded
    string, if it had any (see issue 7143).

You're right though, it does add a newline. I've repushed using b64decode and b64encode for consistency.