Added memory write logic

Added the memory write logic for the three different sizes of access (32
bit, 16 bit and 8 bit). Not very sure that the buffer shifting method
works (check TODO).Will need to test this