code: def save_png_bytes_io(self):
          
          bytearr = QtCore.QByteArray()
          buf = QtCore.QBuffer(bytearr)
          buf.open(QtCore.QIODevice.WriteOnly)
          self.contents.save(buf, "PNG")
          bio = io.BytesIO(bytearr.data())
          # DPI correction
          img = Image.open(bio)
          img = img.resize((self.screen_size[0], self.screen_size[1]),
                           Image.ANTIALIAS)
          img.info["dpi"] = (96, 96)
          converted = io.BytesIO()
          img.save(converted, format='png')
          return converted
docs: Save contents as PNG format file(BytesIO object)
          Note: DPI is platform dependent due to QPaintDevice DPI handling.
          Mac -> 72dpi, Ubuntu -> 96dpi