title: displaying a image created with chunkypng directly (w/o saving)
body: <p>so i created a PNG image using <a href="https://github.com/wvanbergen/chunky_png" rel="noreferrer">chunky_png</a>. i don't want to save this image, because its only useful for this one request, so i'm trying to save this image as an instance variable and displaying it in my view.</p>
  
  <p>the problem is that this results in an <code>invalid byte sequence in UTF-8</code> error in my view.</p>
  
  <p>what i did:</p>
  
  <pre><code># controller
  @img = source_img.resize(200, 200).to_string
  
  #view
  &lt;img src="data:image/png;base64,&lt;%= @img %&gt;" /&gt;
  </code></pre>
  
  <p>debugging the @img variable with <code>raise @img.to_yaml</code>  outputs me the correct string, f.e.:</p>
  
  <pre><code>--- !binary |-
      iVBORw0KGgoAAAANSUhEUgAAAMgAAADIAQAAAACFI5MzAAACP0lEQVR4nO1Y
      QY6jQAy0AxJ9a34AH8l29lmRhgDJSDxrwsxHmh80N5Ag3urkjFZabTw5TJ+g
      HclWUa6ys5Ots6Ot8xP5/xFhnJIGxo/GdDD9HC+al6iNMpGFVie3kXOiyZET
      8bq49cAipRn5bVXOB+CVPiXPXyMRhQb1PDvPRmQZAMWOam/cN1TgpKFEyIVT
      pENLDF6oVoCuSCkdSIokEJnICy41K+AojX4psutY5+8011m80O1T4YpXxsOJ
      3mjqo2A8Jc+/RD7txVNhWFrJPDnTF41uBfPvoXKJHw/jjt7QLMThqKuj2Ufe
      +bUEFDeigtykr1UsVQkT2TP0cjA0H6wuR4VPkKilmMCDACjISmhLXc/64Ap+
      mp3RJZ3IFTVpe9aXXHxawKzOY/Ss8WCVHX2u7hjYNa/yxNsWSrEULzJT0Cd1
      XgToXEDWx/WgWRtPHKkZGSJ86ccDHjqvy9E1ryHfKORkmwJ+5u7NoqoUoXXQ
      axqTYS6Ng2jWukoBD6/7qI+2sc2AmUIKLnUxkHzFMDURVXdHx3hT97pd8hU6
      v9B8Ghs0qOnhIO9PybMZQRuumKTM42Ii3o2zew2lYLnBvRKP9ryErjeEd10/
      fexmaznti8ZWbopoJV5XKeIGJp6TUEEyDGVXZbV8bGCMqRPbTyQnlpDjNzAk
      gZXbNhxLINKH5+XZjsxsJD8DAwjGPtf+CnEDI8xVIX4HQ4aDtlLEDSzx5hdk
      M77FuUp5/9mKPHazu5LX97+wMH42qhX8RP4AQpEyh+7r4x0AAAAASUVORK5C
      YII=
  </code></pre>
  
  <p>copiing this string manually into the img tag displays the image correctly.</p>
  
  <p>any ideas whats going wrong here? other ideas of displaying this image directly without saving?</p>
  
  <p>thanks in advance! if something is unclear, PLEASE leave a comment.</p>