Wire endTransmission freeze sketch

Hello
I'm trying to work with an Atmel 328p-pu with 8MHZ clock and 3.3V. I'm using this type of board:

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x06
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

I have connected a Microchip MCP23016 I2C port expander. with 5v and 16MHZ clock (standard arduino UNO) everything works good. But If I try with 8mhz 3.3v the Wire library freeze mi sketch.

After some hours I found the problem in Wire.endTransmission function.
I think the problem is in twi.c file in the twi_writeTo function.

There are two "while" (line 202 and line 242) that loop forever and freeze.
I'm not able to fix it, any idea?

Have a nice day.