def toBytes(data):
    """
    Formats data into bytes.

    Converts the data to a dict, calls a string representation, then
    encodes the string in utf-8 bytes.

    """
    return str(dict(data)).encode('utf-8')
