Add support for python3

This branch adds python3 support 

There are a number of commits that set the stage for the rest of the code but those are fine grained so should be easy to check