Add gif writing.
Fix direction.  Respect mode flag
DRY up the code
Merge pull request #1 from jonbodner/master

Write to gif instead of console