Add convenience functions for reading and writing whole files. See #595.