Update generate.py

Improve comments, set encoding to allow for funny " character, so works in 2.7