title: Convert png to jpeg using Pillow
body: <p>I am trying to convert png to jpeg using pillow. I've tried several scrips without success. These 2 seemed to work on small png images like this one.</p>
  
  <p><a href="https://i.stack.imgur.com/m2GGn.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/m2GGn.jpg" alt="enter image description here"></a></p>
  
  <p>First code:</p>
  
  <pre><code>from PIL import Image
  import os, sys
  
  im = Image.open("Ba_b_do8mag_c6_big.png")
  bg = Image.new("RGB", im.size, (255,255,255))
  bg.paste(im,im)
  bg.save("colors.jpg")
  </code></pre>
  
  <p>Second code: </p>
  
  <pre><code>image = Image.open('Ba_b_do8mag_c6_big.png')
  bg = Image.new('RGBA',image.size,(255,255,255))
  bg.paste(image,(0,0),image)
  bg.save("test.jpg", quality=95)
  </code></pre>
  
  <p>But if I try to convert a bigger image like this one</p>
  
  <p><img src="https://upload.wikimedia.org/wikipedia/commons/9/92/Ba_b_do8mag_c6_big.png" alt=""> </p>
  
  <p>I'm getting</p>
  
  <pre><code>Traceback (most recent call last):
    File "png_converter.py", line 14, in &lt;module&gt;
      bg.paste(image,(0,0),image)
    File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1328, in paste
      self.im.paste(im, box, mask.im) ValueError: bad transparency mask
  </code></pre>
  
  <p>What am i doing wrong?</p>