Fix resource leaks by using weakrefs to avoid circular references.

Tested with pisa==3.0.33 (from PyPI) but the same circular reference
seems to exist here.

Reproducing:

Create a PDF with a (large) @page background PDF. Do this a couple of
times in a long running application and you'll see more and more file
handles reference the background-pdf. (That's just a symptom of objects
not getting garbage collected.)

After applying this fix, the file handles are released and the
excessive memory usage is gone. That leads us to believe that this
fixes the problems we were having.

In our case, when reproducing, we still had /some/ file handles open
after the fix, but an explicit call to `gc.collect()` cleared those too.