Set the meta charset before serializing

When serializing html documents, the encoding can be specified overridden by a meta tag in `head`.  This ensures that when we output the document, we specify the encoding.  If the encoding has not been specified, we leave the meta tag uncreated.