fixed inversion bug + refactor

fixed a bug where clicking invert and then sliding brightness (for
example) inverted the image again. Also refactored the code so that all
callbacks use a processImg function ( consistent behavior ) and also
added some helper functions that I now have to add to processImg.