The PAM output currently calls fwrite for every pixel, which amounts to
about half a million fwrite calls to output a full screen image. For a
fullscreen animation like logo.lbx.001, the majority of the execution
time is spent in fwrite.
Let's reduce this a lot by formatting and outputting an entire row at
a time, which almost completely eliminates fwrite from the profile.