Moved to a new topic instead of resurrecting old thread that deals with a different issue. This appears to be related to a specific error.
OSError: cannot write mode RGBA as JPEG
Please see the Google results that discuss this error to see if it can help.
For example:
Let us know if the solutions there help you out. For example:
im = im.convert("RGB")