def byteify(element):
    """Converts unicode elements of dict or list into str.
    # Source:
    # http://stackoverflow.com/questions/956867/how-to-get-string-objects-instead-of-unicode-ones-from-json-in-python
    """
    if isinstance(element, dict):
        return {byteify(key): byteify(value)
                for key, value in element.items()}
    elif isinstance(element, list):
        return [byteify(element) for element in element]
    elif isinstance(element, str):
        return element.encode('utf-8')
    else:
        return element