For file files in memory you can use StringIO. Take a look:
from io import StringIO
from PIL import Image
im1 = Image.open(IMAGE_FILE)
buffer = StringIO.StringIO()
im1.save(buffer, "JPEG", quality=10)
with open("./photo-quality10.jpg", "w") as handle:
handle.write(buffer.contents())
If you check the file photo-quality10.jpg, it should be the same image, but with 10% quality, as when setting JPEG compression.