title: PySide2: TypeError: 'bytes' object cannot be interpreted as an integer
body: <p>I have this PySide2 code which works on Linux with Python 2.7</p>
  
  <pre><code>from PySide2.QtCore import QBuffer, QByteArray
  
  ...
  
  image = self.clipboard.image()
  ba = QByteArray()
  buffer = QBuffer(ba)
  buffer.open(QIODevice.WriteOnly)
  image.save(buffer, "PNG")
  return bytes(buffer.data())
  </code></pre>
  
  <p>But on windows with Python 3.6 it fails here:</p>
  
  <pre><code>  File "C:\....foo.py", line 93, in image_to_png
      return bytes(buffer.data())
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>TypeError: 'bytes' object cannot be interpreted as an integer
  </code></pre>
  
  <p>What is the most simple way to get the PNG as bytes?</p>
  
  <p>I would like to avoid to create a temporary file, since it is not needed for this context.</p>
  
  <p>(I use PySide2, but I could switch to a different python-QT binding if you think it makes more sense. Please leave a comment if you think so)</p>