Fix templating to return correct mime types and do safe html/xml escaping

This should also fix #126. The problem was that the template system
was set up for html only and so would produce the wrong mime type when
used for text templates. We now pick the mime type and the escaping
mechanism based on the template file extension, .html.st vs .txt.st

So also have to rename some templates that were not following the naming
convention.

Also use more template type instances to simplify the code where do the
template substitution.