Fixes to printing

TODO wait for @jrioux to comment

This fixes issue 3354 (printing of Piecewise), and also offers a better fix to
issue 3260 (#1788, printing of powers of Integral).