Fixed writing of netcdf files