<PAGE>

                                                                   EXHIBIT 10.12

                           AMENDMENT TO LOAN AGREEMENT


                   THIS AMENDMENT TO LOAN AGREEMENT (the "Loan Agreement") is
made this 29th day of July, 2004, by and between LYLES DIVERSIFIED, INC., a
California corporation ("Lyles") and PACIFIC ETHANOL, INC., a California
corporation ("PEI").

                                    RECITALS:
                                    ---------

                  A. The parties entered into that certain Term Loan Agreement
("Loan Agreement") dated June 16, 2003.

                  B. Paragraph 1.5 of the Loan Agreement granted Lyles the right
to purchase up to a total of $1,500,000 worth of common shares of PEI at the
fixed price of One and 50/100 Dollars ($1.50) per share up to and including
March 31, 2005. The Loan Agreement provided only for purchase of the stock by
conversion of debt owing under the Loan Agreement; the parties, however,
intended for Lyles to have the option to purchase stock or to convert debt. The
parties now desire to enter into this clarifying amendment to ensure that
Paragraph 1.5 of the Loan Agreement reflects the intentions of the parties.

                   NOW, THEREFORE, the parties agree as follows:

                  1. CLARIFICATION OF PARAGRAPH 1.5: The parties hereby amend
Paragraph 1.5 of the Loan Agreement to state in its entirety as follows:

                   1.5 RIGHT TO PURCHASE COMMON STOCK OR CONVERT DEBT TO COMMON
STOCK: Lender shall have the right, at Lender's option, to purchase common stock
or to convert up to $1,500,000 of the principal owing to common shares of
Borrower. Any principal converted shall be considered paid on the date of
conversion and shall cease to accrue interest as of that date. Lender may
purchase for cash or by conversion of debt up to a total of $1,500,000 worth of
common shares at the fixed price of One and 50/100 Dollars ($1.50) per share.
Lender may purchase shares under this right up to and including March 31, 2005.
Lender shall have no right pursuant to this Agreement to purchase common stock
or convert debt to stock ownership following that date. The expiration date for
the rights granted in this paragraph cannot be extended irrespective of any
performance, or lack of performance, of Borrower under the Loan Documents. If
Borrower intends to prepay the principal prior to March 31, 2005, Lender shall
have the option to exercise its right to convert debt to common stock (as of the
date of the proposed prepayment) in lieu of accepting the prepayment.

                  2. NO FURTHER AMENDMENTS: Parties do not intend any additional
amendments to the Loan Agreement. All its terms and conditions shall continue in
full force and effect unless and until they are amended according to its terms.

                                       1
<PAGE>



                  IN WITNESS WHEREOF, the parties hereto have caused this Loan
Agreement to be executed as of the date first above written.




LENDER:                                 BORROWER:

LYLES DIVERSIFIED, INC.,                PACIFIC ETHANOL, INC.,
a California corporation                a California corporation


By /s/ William M Lyles                  By /s/ Neil Koehler
   -------------------------------         -----------------------------
William M. Lyles, President                Neil Koehler, CEO


By /s/ William Lyles                    By /s/ Ryan Turner
   -------------------------------         -----------------------------
William Lyles, Vice-President              Ryan Turner, Secretary/ COO


                                       2