Fix for encoding issues with non-ASCII sites.

This encodes at the file level for HTML - meaning that we can work in unicode the entire time. Since the built in CSV writer doesn't support unicode we encode immediately before writing each row.