can be extended to arbitrary sizes
fixed colors, moved memcpys to appropriate place