Add open(), read() and write() functions

This is the combination of a few commits from #18.
See also #14.