import base64


def b64encode(s):
    """Return argument as b64encode encoded str."""
    try:
        s = s.encode('ascii')
    except Exception:
        pass
    return base64.b64encode(s).decode(errors='strict')