Replace filename. From http://stackoverflow.com/questions/5953239/how-do-i-change-file-extension-with-javascript