Maybe putting the result of the prediction into a raster directly will work for you as well (I usually do this and there is no such problem with it). I execute a cluster:
Be aware that predict.randomForest(, type = "prob") will give you a matrix as result, instead of a vector, that is required by raster::predict(). You should give a try to