Fixed While-statement assertion. Implemented DrawToImage and DrawToScreen
Added a test for DrawToImage