title: Opening in-memory image with Pillow raises `TypeError: 'unicode' does not have the buffer interface`
body: <p>I'm reading an image, encoding it to base64, and sending it as part of a payload to a Flask app.  In the app, the string gets decoded and checked for validity by loading it with <code>PIL.Image</code> and <code>io.BytesIO</code>.  When I run the steps in a shell, they execute correctly.  When I run the server and pass the data from the client, I get <code>TypeError: 'unicode' does not have the buffer interface</code>.  Why do I get this error and how do I fix it?</p>
  
  <pre><code>with open(args.pngfile) as f:
      payload['image'] = f.read().encode('base64')
  requests.post(URL, json=payload, headers={'Content-Type': 'application/json'})
  </code></pre>
  
  
  
  <pre><code>image_str = request.json['image']
  decoded_image_str = image_str.decode('base64')
  Image.open(io.BytesIO(decoded_image_str))
  </code></pre>
  
  
  
  <pre><code>Traceback (most recent call last):
    File "/home/parin.porecha/image_service/image_service_venv/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
      response = self.full_dispatch_request()
    File "/home/parin.porecha/image_service/image_service_venv/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/home/parin.porecha/image_service/image_service_venv/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/home/parin.porecha/image_service/image_service_venv/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
      rv = self.dispatch_request()
    File "/home/parin.porecha/image_service/image_service_venv/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "./application.py", line 35, in compress
      response = compress(request)
    File "./processor.py", line 56, in compress
      Image.open(io.BytesIO(decoded_image_str))
  TypeError: 'unicode' does not have the buffer interface
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Python 2.7.3
  Flask 0.10.1
  Pillow 2.9.0
  </code></pre>