python2/3 compatibility

I split the commits.