Set template encoding correctly

When partials for templates were created the encoding of the output was
not properly set.  This would lead to encoding errors when invalid
characters where generated while writing to the main page.

Now the template source is transcoded to the output encoding which
allows the template result encoding to be correct.

This issue resisted efforts to write a proper test-case.

Fixes #183