allow saving and loading in ast format

@jimfleming, this was my attempt at trying to support loading/saving as AST, I dont expect it to be perfect, but a random attempt.

tries to take care of #102
Do we want a try/catch here or just let it error?