Use the proper string type according to python version

`dumps` makes several type comparisons in one of its generation steps. One
of these is against the string type. But the string type used is
specific to Python 2, and it fails on Python 3.

This commit uses six ( https://pythonhosted.org/six/ ) to compare to
the proper string type according to the Python version being used.