Added functionality to save images. Currently in a really rough state. Will refactor in another commit.