Save png image using nodejs and socket io in flash

I need to save image from flash to server using node.js . here i my code.

var pngEncoder:PNGEncoder = new PNGEncoder();
var pngStream:ByteArray = PNGEncoder.encode(bmd);
socket.send(pngStream,"image");

that's my flash code and below is my js code

var data = new Buffer(d,'binary');
 fs.writeFile("image.png", data);

My node version is 0.10.30 Socket.io version is 0.8

Please help me.

I found a way to do this. Please check my blog here. I encoded the ByteArray to a BASE64 string and passed it to the node.js server. I can't send data as binary to the server. BUt converting it to BAse64 worked for me. I have documented what i have done in here.