fixed NullPointerException bug in save image