title: PIL Image to QImage crash and distortion
body: <p>I am using Pillow to load an image in the background and pass it to the foreground of my PyQt app as bytes, to then convert it to a QImage to display in the GUI. The majority of the time this works great, however it seems that if my image is not divisible by 2 in either dimension then the QImage is distorted or the app crashes. I made a test of this by loading a jpeg which was 341x512 and it came out black and white and with horizontal stripes, and then just by resizing it in photoshop to 340x512 it loaded perfectly. I then resized it to 339x512 and it came out distorted again.</p>
  <p>This clearly has something to do with <code>image.tobyes()</code> interacting poorly with the QImage constructor. I am just guessing that the bytes are somehow getting rounded, or something like that? I'm really not sure what the issue is, I assume bytes are just bytes but clearly that is wrong.</p>
  <p>How can I fix this? What is QImage expecting that PIL is not providing? Here's a sample script:</p>
  <pre><code>from PIL import Image, ImageQt
  
  im = Image.open('')
  im.convert('RGB')
  bytes = im.tobytes('raw', 'RGB')
  
  
  # at this point in my app the bytes get sent back to the main process from a sub-process.
  
  
  app = QtWidgets.QApplication(sys.argv)
  label = QtWidgets.QLabel()
  im = Image.frombytes('RGB', im.size, bytes) # &lt;- 'bytes' comes in from a Manager
  label.setPixmap(ImageQt.toqpixmap(im))
  label.show()
  sys.exit(app.exec_())
  </code></pre>