Use six to test for string type
In Python 3 we can't rely on dict ordering
unicode doesn't exist in Python 3
Use string_types instead of basestring
iteritems has been removed in Python 3