moved image loading function to require.js