Recode to print directly to PNG device

Had to change all codes to print directly to the PNG device so that it
could fit the dimension.