Thanks to Martin Lormes for suggesting this change and writing the initial implementation, which was inspired by a feature in the default WordPress theme Twenty Eleven.
This commit brings two changes: replacing the use of the deprecated add_custom_image_header function, and no longer defining header image constants, as these are now defined by the add_theme_support function when called with the 'custom-header' argument.
Setting the post and page sidebar to use the same widgets as the main sidebar was irreversible: unticking the checkbox and saving the option had no effect. This commit fixes that bug so the feature works correctly. Thanks to Andrey Bazhan for reporting this issue.