gmakegen*.py: use with statement for file handling
Better handling of error conditions and potentially lingering file handles.
@sbalay I'd mildly prefer this in the release, but it probably doesn't affect anyone and I realize it's past the freeze so no biggie either way.