fix #3 output stream does not preserve order of input stream

@dominictarr Let me know if this is ok.  It required a bit of refactoring.

The basic idea is that we keep a hash ``writeQueue`` of items that have yet to be written.  If an item comes back and it's not time for it to be written, it gets added to the queue.  Also, we check the queue for items to be written in every ``next()`` call, and after every ``write()``.