Added save method

Fixes #584