graphics: Make textgen script work with Python 3.

Also add copyright notices to Python files.