Fix syntax errors in Python 3.x