Optimized writing to the content memory stream, should noticeably improve performance