Got HTML output working, except for a UnicodeEncodeError which is being caught somewhere