Fix unstructured data output conflict with topo_type writing

Also fix bug when not writing a masked array