import io from PIL import Image # Encode your PIL Image as a JPEG without writing to disk buffer = io.BytesIO() YourImage.save(buffer, format='JPEG', quality=75) # You probably want desiredObject = buffer.getbuffer()