Fix for FLINK-708 and FLINK-887 

I tested Flink on Amazon EMR (Hadoop 2.4.0). It was necessary to change some code due to a API change in YARN. Flink should now support all Hadoop versions >= 2.2.0.

I also fixed the JobManager heap space calculation for YARN. The JM sometimes failed one large jobs.

I would like to include the commit into the 0.5.1 release.