Python 3 fix for #509.

In Python 3 'unicode' will raise a NameError as all strings are unicode
there and 'unicode' is not available. This fix will fallback to previous
code if we're running on Python 3.

Because of native unicode support in Python 3 the original issue (#508)
should surface.