Encode as UTF-8
Only include header if not empty