modified to read images synchronously if running in node and if the images are local