Optimize encoding of websocket frames by merge if possible