Fixed some bugs in the Html5 writing routines