rewrite Store.Memory.write to avoid string copying and special-case append