Optimized the saveAsImage plugin

Optimized the saveAsImage plugin