MetadataTemplate to file

Adds the `to_file` functionality to the metadata templates