Clean up code that creates PETSc viewers.

Incidentally, this fixes a couple of bugs/deficiencies:
- Write NetCDF instead of HDF5 when NetCDF is requested
- Allow reading of VTK
Extract common code from PETSc read and write routines into subroutines.
Merge pull request #394 from ketch/petsc_viewer_cleanup

Clean up code that creates PETSc viewers.