Clean up code that creates PETSc viewers.

This PR simplifies the logic in petsc.py for creating PETSc viewers for different formats, and extracts this logic out of the read/write routines into a separate common subroutine.

Incidentally, this fixes a couple of bugs/deficiencies:
- Write NetCDF instead of HDF5 when NetCDF is requested
- Allow reading of VTK