Fix a few bugs in profile icon handling, especially when deleting profile icons:
* Make sure all of the database work happens before deleting the image from disk, and do it in a transaction. This means that if the database reworking fails, the image won't be deleted accidentally. * Make sure to clear the profileicon out of being in the view_artefact table * Set a new default icon if the existing default is being deleted. This behaviour will change later, see bug #1774.