Only calculate reduced width for color indexing once
factor out error check when applying transforms
Some code refactoring and cosmetic clean up