Make serializing DOM nodes better

1. Format them as HTML 2. Catch any errors that still occur