Avoid unwanted artifacts when creating JPNG files using JPNGTool

A few improvements, but the biggest thing this pull request fixes is some unwanted artifacts that show up when creating some JPNG files using JPNGTool on MacOS.

Because the CoreGraphics API on the Mac by default would treat all transparent data as white when converting to JPEG, some of this would end up bleeding on the edge of transparent images and would show up when loading the JPNG file. This  patch fixes this by explicitly making it use the clear color instead of white.

By the way I think it would make sense to use the same CG code for iOS since these APIs have been available since iOS 4.0 and there is really no point in supporting anything older. I haven't found a similar option for `UIImageJPEGRepresentation()` so if the problem exists on iOS (which I haven't tried) it may not be fixed there.

Otherwise, moved away from using the legacy `memcpy()` C APIs for the more secure NSData equivalents, since they're here and available.