Merge pull request #6 from fancycode/refcount_buffers

Use refcounted buffers for IO.