implement file-like object interface

fixes #3