tweaked PatternImage constructor and main