fix bogus checks against unsigned variables.

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix some pieces of nonsensical code

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix some precedence errors

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix some copy&paste errors

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix parser for plugin image types

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix bogus use of g_strlcpy

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix errors in the psd loader code.

triggered by Andrey Karpov finding a stupid if-elseif-elseif-... sequence
using static code analysis:
   http://www.viva64.com/en/b/0273/
remove unnecessary if()

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/
fix a few potential use-before-check errors

Spotted by Andrey Karpov using static code analysis:
   http://www.viva64.com/en/b/0273/