Add support for printing

Fixes #296.