Add normalizeFormat() method in GD driver

Makes code less confusing by separating concerns (and avoiding pass-by-reference).
Small fixes

Fixes a typo, removes an useless array entry.
Merge pull request #292 from vlakoff/gd-normalize-format

Add normalizeFormat() method in GD driver