fix stream#write context issue