Added null-check when creating legend images in printing module to preve...

...nt null-pointer-exception