unified glob matching for stack loader

Made a function that can be used from ilastik to match glob patterns. Fixes ilastik/ilastik#661.