Bug 871647 - Add file extension support for filename generation in utils

https://bugzilla.mozilla.org/show_bug.cgi?id=871647