Python 3 fixes (so that it works without 2to3)