writing encoding table - really slow