I wish I could have done it myself in Python though.
You can still do that now.
Find one file which works and one which fails, open them both up in a good image editor which will tell you more about the file internals and see if you can find a difference in encoding or encoder or settings or something. Is there a PIL file size limit? What are the permissions like on the files? Does 'file'(?) identify it as a JPEG?