Python3 Compatibility

Some fixes to provide python3 compatibility