Added output stream implementation, based on work by Carl Lindberg.