The data-widget="uploadimage" attribute is removed too early. Therefore, the "uploadimage" plugins is not taking over the upload and the image is never actually uploaded and substitued with the upload result (hence the black square).