fix stream wrapper to make initial encryption work