Python 3 compatibility work

A set of work that addresses python 3 changes for this library from basic Python 2to3 changes to more advanced and nuanced changes. Please review carefully.