How to rewrite the ouput html of the image field for a node page?
This looks like output coming from theme('field') theme function in field.module. You can override the output by putting the following function in your template.php:

/**
 * Implements template_preprocess_field
 */
function mythemename_preprocess_field(&amp;$vars) {

}


More info on the preprocessor (with examples of how to add additional classes) is here: template_preprocess_field

EDIT:
Actually looking at the theme function, it seems that in your case I think you need to implement both a preprocessor and a template file for your field. So in the preprocessor you create a variable for the class:

/**
 * Implements template_preprocess_field
 */
function mythemename_preprocess_field(&amp;$vars) {
  $element = $vars['element'];
  if ($element['#field_name'] == 'field_myfieldname') {
    $number = 123; // This variable should get the value you wish to attach to the class
    $vars['field_myfieldname_custom_class'] = 'field-item-' . $number;
  }
}


And then create a field template file field--field_myfieldname.tpl.php and put &lt;?php print $field_myfieldname_custom_class; ?&gt; where the class should appear.