Support for giflib 5+

Signed-off-by: Alberto García Hierro <alberto@garciahierro.com>
Fix saving animated gifs with giflib 5.x

The APP extension was not correctly saved, since its blocks were
ignored (only the leader and the trailer was written).
Merge branch 'fix-giflib5'

Fixes #11, fixes #12.
Thanks to @etix for initial code.