Copy image in more platform-independent way