Beginning of porting to python 3

Not a complete port, but should be a good starting point. Syntax/import/function issues are fixed, mostly using the "six" module. Python2 still works with no change in behaviour (hopefully). Python3 successfully starts up, but without any results and crashes on any interaction.

Feel free to use / build on top of it.