[SPARKR-136] Use SPARK_LOCAL_DIRS to create tmp files

This implements the same logic as in https://github.com/apache/spark/blob/branch-1.1/core/src/main/scala/org/apache/spark/util/Utils.scala#L515
Its unfortunate we can't use that directly as Utils is private to Spark.