fixed extension issue (issue #862 )

On file with multiple dots, extension is broken
Eg: on {ext:'.js'} myscript.prod.dust => myscript.js, instead it should
produce mysqcript.prod.js