If you already have a binary jpeg memory, then you just need to fopen() a file and fwrite() the data.