Fix astext for python3 and support inline elements