Add SerializeToStream method.