use StringIO in LZW to make it not O(N^2)

This takes importing one particular large app from ~650 seconds to ~25 seconds.