Fixed extracting layers from image

Before it threw an exception because #{filename}.#{newformat} didn't
exist, but when extracting layers we should check for #{filename}-0.#{newformat}.