title: How to write a base64 decoded png image to file?
body: <p>I try to write a base64 png image to file with following code: </p>
  
  <pre><code>imageReader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(Images[i]))
  pngImage, _, err := image.Decode(imageReader)
  if err != nil {
    beego.Error(err)
  }
  bounds := pngImage.Bounds()
  if imgFile, err = os.Create(fileName + ".png"); err != nil {
     return Data{}
  }
  defer imgFile.Close()
  _, err = imgFile.Write([]byte(pngImage))
  </code></pre>
  
  <p>The bounds are ok. The error message for the last line is </p>
  
  <blockquote>
    <p>cannot convert pngImage (type image.Image) to type []byte</p>
  </blockquote>
  
  <p>Obviously, because an image.Image is not a byte[]. But how can I convert it? Or is there even a simpler version to do this.</p>