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.
FILE *fp = fopen("C:\\myimage.jpg","ab");
long size = ftell(fp);
char *buffer = (char*)calloc(500*1024-size,1);
Note that I consider this quite an ugly hack, but it's up to you to decide if you wish to use this.