Fix for NPE crash (issue #69)

Closes #69
Trim trailing spaces.
Losslessly compress images.