I found a fix to this error. Just don't change the ArcGIS default output location when running the tool. You can change the name of the output file though. But let it save in the default directory given by ArcGIS (somewhere in User-Documents-ArcGIS-...). And if the default path is something else (maybe a colleague changed it or something) then that is not considered as the default path. It should be ArcGIS defult path in the location I roughly mention above.
The output raster needs to be saved in a file geodatabase instead of a normal folder. This should stop the unknown error: 999999. The extract by mask script will not work if the save location is not in a file geodatabase.