Clever read and write utilities for buffers