Fix issues in imagemanager

XSS issue reported by Manuel Garcia Cardenas
Broken categories list
Some PSR-2 formatting cleanup