Support template mimetypes

Unless I forgot something the only difference between template versions and normal documents is the mimetype.