import base64


def b64encode(data):
    """JOSE Base64 encode.

    :param data: Data to be encoded.
    :type data: bytes

    :returns: JOSE Base64 string.
    :rtype: bytes

    :raises TypeError: if ``data`` is of incorrect type

    """
    if not isinstance(data, bytes):
        raise TypeError('argument should be bytes')
    return base64.urlsafe_b64encode(data).rstrip(b'=')