XObject.str() fails the second time it is called. Makes debugging difficult. Get the result string early.