Python3/2 compatibility support.

All tests pass for Python3 and Python2 on my local machine and should on the CI too.