Make the output function an instance variable
Add an optional `stream` parameter for output

This outputs each written element to `stream.write()`.

When a stream is used, `unicode()` and `str()` return empty strings.
Fix the broken element chaining

This never worked correctly.

Now, chaining creates elements at the same level as the first one.
Enable chaining after item access