Implement toStream() method.