Handle buffers as well as streams