GD error catching

This actually comes from @odcinek based on his BM changes
but it didn't get committed yesterday.
Merge pull request #39 from jaymzh/fix_git_gd

GD error catching