import six
import base64


def b64encode(source):
    """Base-64 encoding method compatible with python2 and python3.
    """
    if six.PY3:
        source = source.encode('utf-8')
    content = base64.b64encode(source).decode('utf-8')
    return content