PDF:  Changes to error reporting, to handle non-UTF8 error output.
beamer template:  changes for better unicode handling.

Ported from LaTeX template.  Thanks to KarolS for the patch.