Support template mimetypes

Unless I forgot something the only difference between template versions and normal documents is the mimetype.

Fixes #744.
Fixes #746. (still not sure if this is the best API)
> How would you propose that they learn about new features in the API?

That is a good question. Your current description doesn't provide many hints in this direction, but we don't really have a good approach to distributing examples like this. Perhaps major features such as this could benefit from a wiki page on github?