Fix from @kotowicz to fix filename encoding. Closes #162 and #149