fixed a few bugs, added option for exporting images