a port for python3
add some ifdefs to make it compile on python2
Merge remote-tracking branch 'upstream/master'
Merge pull request #1 from rpodgorny/master

Python 3 fixes