Hook into output stream, fixes #1