def get_bytes(data):
    """
    If data is not bytes, encode it.

    :param data: the input data
    :return: the bytes of data
    """
    if not isinstance(data, bytes):
        data = data.encode('utf-8')
    return data
