the assert should still be there. the added lines below are almost correct though: they may need to account for the number of bytes per pixel