Support generic streams, not just Buffer

@purplefox can you review this ?