OSError: cannot write mode RGBA as JPEG
im.convert("RGB").save("out.jpg")
This works, but it puts black behind anything transparent, which is rarely what you want.
from PIL import Image
im = Image.open("logo.png").convert("RGBA")
flat = Image.new("RGB", im.size, "white")
flat.paste(im, mask=im.split()[3])
flat.save("logo.jpg", quality=88)
A white background, with the alpha channel used as the mask so the edges blend properly instead of turning into a ragged outline.
JPEG stores three channels and has no concept of transparency. PNG screenshots, logos and anything with rounded corners arrive as RGBA, and the error appears the moment you try to save one with a .jpg name.
Palette images with transparency and greyscale with alpha fail the same way. convert("RGB") handles both, and the paste trick above works for them too once you have converted to RGBA.
If you do not specifically need JPEG, save as PNG or WEBP and the problem disappears. WEBP supports alpha and is usually smaller than both. The converter shows the size difference on your own files.
The PIL to Pillow converter finds most of these automatically, and the other error pages cover the rest.