Added support for guessing the file extension.