Implement stream encoder