Implement mapscript API for iterating outputformats of a map, ticket #4552

Added RFC24 memory management for mapscript and created Java mapscript example and tests.

Note: iterating format options in #4553, due next