use HDF5File class in {read,write}HDF5 functions

Besides reducing code duplication, these patches fix

 * bug in `readHDF5` where chunked / compressed data was not read properly
 * bug in `read`/`write` methods of `HDF5File` where complex datatypes such as `RGBValue` led to segfaults