Fix dump() in TemplateStream class for Python 3.x.

The built-in file type has been removed at Python 3.0.