Fixes for Python 3 with 2to3

Small fixes for Python 3.