optimization in writeLongString() and fix size for nprintf()

writeLongString() do not need do duplicate the data being written each time.