Add jpg support for state chart image saving

Changes to Peter's patch:
- Initialize 'quality' variable right away with -1
- Use case insensitive matching for file name end

Fixes #35