more Python3 syntax fixes, introduce compat2and3 module