I was playing around and did something similar with video encoding. The server code starts a running ffmpeg process, and then the handler code just looks like this:
server = http.createServer(function(request, response) {
request.pipe(ffmpeg.process.stdin);
ffmpeg.process.stdout.pipe(response);
});
What a nice interface! The end result is that you can do weird stuff like: