change PutPixel, add SafePutPixel
add an example of main