Save and restore functions

This PR adds basic save and restore functionality for text and images.