Extract file writing logic from Template.

I think it's a bit awkward for the Templater class to have to know how to save files to disk. This means that a Generator has to use a Templater instead of, say, outputting a bunch of JSON itself.

This change pulls out the logic that decides where and how a file is written into a separate class, Writer. The writer is created in the Generator, so the creation code can be shared by Generator subclasses (if that will happen) and so that Generators can call the writer directly to output some JSON.