Enhance 'beforeupload' event

Implement possibility to wait until 'beforeupload' finishes processing.