Cleaned Write3DtoHTML and Write2DtoHTML