- added "save as jpeg" functionality
- organized the code