title: ValueError: Fileobj must implement read
body: <p>I am converting gif images into jpgs using PIL library and uploading them to s3. I get this error:</p>
  
  <p>ValueError: Fileobj must implement read</p>
  
  <p>here is part of code that reads the image and convert to jpgs:</p>
  
  <pre><code>im = Image.open(url)
  i = 0
  mypalette = im.getpalette()
  try:
      while 1:
              im.putpalette(mypalette)
              new_im = Image.new("RGBA", im.size)
              new_im.paste(im)
              key = 'img'+str(i)+'.jpg'
              in_mem_file = io.BytesIO()
              new_im.save(in_mem_file, "JPEG")
              s3.upload_fileobj(in_mem_file.getvalue(), bucket, key)
              i += 1
              im.seek(im.tell() + 1)
  except EOFError:
              pass
  </code></pre>
  
  <p>I use io.BytesIO to get read the bytes however I still get the same error. if I remove getvalue from in_mem_file empty images are saved in the bucket.</p>