Fix errors in uploading pictures and saving them to the DB