Bug 1065877: prevent OOMs when editing, picking and sharing large images

address review comments
Merge pull request #24129 from davidflanagan/bug1065877

Bug 1065877: prevent OOMs when editing, picking and sharing large images r=russnicoletti