Converted image file reading to use regex.