I don't agree with the statements that it's not possible, you can safely pad an existing JPEG file which is under 500Kb with zeros to increase the length to 500Kb. It works for GIF files too.
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
FILE *fp = fopen("C:\\myimage.jpg","ab");
fseek(fp,0,SEEK_END);
long size = ftell(fp);
char *buffer = (char*)calloc(500*1024-size,1);
fwrite(buffer,500*1024-size,1,fp);
fclose(fp);
}
Note that I consider this quite an ugly hack, but it's up to you to decide if you wish to use this.