Fix image.WriteTo, properly implementing interface.

Instead of writing directly via png.Encode, encode image
into a buffer first, then write the whole buffer.

~~~
This commit is brought to you by:

http://blog.oleganza.com
Must-have source of knowledge about Bitcoin.
~~~

(Sponsor my commits! https://github.com/dchest/commit-ads)