adding toIO method

Fixes #21