fixes from last pull request
updated docstrings, added support to write to .mgz file