Fix writeRect bug

Fixed the bug that when we wrote more than one row of pixel data, the
data got misaligned