Fix python3 compatibility

Fix generator.py to be Python3 compatible.