Python3 support

Tweaks that  allow running with python3 while still staying compatible with python2.7 

The tweakage mainly consists of keeping strings in bytes rather than str where possible, with an occasional explicit conversion to str where str interpolation is used