title: Django error: io.UnsupportedOperation: read and ValueError: bad mode 'rb'
body: <p>I was getting this error: <strong>io.UnsupoortedOperation: read</strong>
  I made some changes. I changed this line <code>img = Image.open(f)</code> to <code>img = Image.open(f, "rb")</code> After that I get this error: <strong>ValueError: bad mode 'rb'</strong>
  What's the problem here? How do I fix this?</p>
  
  <p>views.py</p>
  
  <pre><code>class LinkCreateView(CreateView):
      model = Link
      form_class = LinkForm
  
      def form_valid(self, form):
          hash = str(uuid.uuid1())
          with open("tmp_img_original_{}.png".format(hash), "wb") as f:
              res = requests.get(form.instance.url, stream=True)
              if not res.ok: raise Exception("URL'de dosya yok: 404")
              for block in res.iter_content(1024): f.write(block)
  
              img = Image.open(f, "rb")
              width, height = img.size
              img.thumbnail(get_size(width, height), Image.ANTIALIAS)
              img.save()
  
              djfile = File(f)
  
              form.img.save("img_tn_{}.png".format(hash), djfile, save=True)
              f.close()
  
          f = form.save(commit=False)
          f.rank_score = 0.0
          f.submitter = self.request.user
          f.save()
  
          return super(CreateView, self).form_valid(form)
  </code></pre>