Fixed serialize logic, added de-serialize

Now properly serializes files to disk, and added de-serialization
functionality.