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