Fix fringing on image borders at certain zoom/size combinations

Thank you to @audioglider for reporting.

Investigations showed this to be a known GDI+ bug.  Thank you to the
following link for a reliable fix:

http://stackoverflow.com/questions/1890605/ghost-borders-ringing-when-resizing-in-gdi

FreeImage has recently introduced a lovely function for directly
accessing image bits from foreign sources, so in the coming weeks, I may
look at switching to their resize functions for rendering the viewport.
GDI+ is not particularly fast, and not particularly high-quality, so I
wouldn't be averse to trying something new.

This commit also includes some performance tweaks for viewport
rendering.  Large images and images with many layers should now render
more quickly.