     
     // Position
     int image_position = gX + x;
-    int image_position_x = image_position % image_width;
-    int image_position_y = image_position / image_width;
+    int image_position_y = gpujpeg_const_div_divide(image_position, width_div_mul, width_div_shift);
+    int image_position_x = image_position - (image_position_y * image_width);
         
     // Store
     if ( image_position < (image_width * image_height) ) {

    
    // Position
    int image_position = gX + x;
    int image_position_x = image_position % image_width;
    int image_position_y = image_position / image_width;
    
    // Store
    if ( image_position < (image_width * image_height) ) {

/**
 * Kernel - Copy raw image source data into three separated component buffers
 */
typedef void (*gpujpeg_preprocessor_encode_kernel)(struct gpujpeg_preprocessor_data data, const uint8_t* d_data_raw, const uint8_t* d_data_raw_end, int image_width, int image_height, uint32_t width_div_mul, uint32_t width_div_shift);
 
/** Specialization [sampling factor is 4:4:4] */
template<
