import six


def make_bytes(dictionary):
    """Encodes all Unicode strings in the dictionary to UTF-8 bytes. Converts
    all other objects to regular bytes.

    Returns a copy of the dictionary, doesn't touch the original.
    """

    result = {}

    for (key, value) in six.iteritems(dictionary):
        # Keep binary data as-is.
        if isinstance(value, six.binary_type):
            result[key] = value
            continue

        # If it's not a string, convert it to one.
        if not isinstance(value, six.text_type):
            value = six.text_type(value)

        result[key] = value.encode('utf-8')

    return result