Fix many syntax errors on Python3.

No actual semantic fixes, so it still doesn't work, but maybe a first step.